using System;
using System.Collections.Generic;
using System.Text;
using VisualDB.Entities;
using System.Data;

namespace VisualDB.DAL
{
    public interface IDatabaseDAL
    {
        DatabaseEntity DatabaseEntity { get; set;}
        List<DatabaseEntity> GetDatabases(out string errors);
        bool IsOpened { get; }
        void Open();
        void Close();
        List<TableEntity> GetTables();
        string RenameTable(string oldName, string newName);
        string DeleteTable(TableEntity table);
        string SaveTable(bool newTable, TableEntity table, List<ColumnEntity> originalColumns, List<ColumnEntity> newColumns);
        List<ColumnEntity> GetColumns(TableEntity table);
        List<ColumnEntity> GetColumns(ViewEntity view);
        List<ViewEntity> GetViews();
        string RenameView(string oldName, string newName);
        string DeleteView(ViewEntity view);
        List<StoredProcedureEntity> GetStoredProcedures();
        string RenameStoredProcedure(string oldName, string newName);
        string DeleteStoredProcedure(StoredProcedureEntity storedProcedure);
        DataSet ExecuteQuery(string query, out string errors);
        int ExecuteCommand(string query, out string errors);
        string GenerateScriptTable(ScriptType scriptType, TableEntity table);
        string GenerateScriptAddEditView(ViewEntity view, bool newView);
        string GenerateScriptSelectView(ViewEntity view);
        string GenerateScriptAddEditStoredProcedure(StoredProcedureEntity storedProcedure, bool newStoredProcedure);
        string GenerateScriptExecuteStoredProcedure(StoredProcedureEntity storedProcedure);
    }

    public enum ScriptType
    {
        Select,
        SelectAll,
        Insert,
        Update,
        Delete,
        NewView,
        EditView,
        SelectView,
        NewStoredProcedure,
        EditStoredProcedure,
        ExecuteStoredProcedure
    }
}
